import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import { createStore } from 'vuex';
import axios from 'axios';
import { ElMessage } from 'element-plus';
import Cookies from 'vue3-cookies';

// 创建 Vuex 存储
const store = createStore({
    state: {
        count: 0,
        userId: 0,
        key: "",
        showtable: "first"
    },
    mutations: {
        userid(state, id) {
            state.userId = id;
        },
        subkey(state, key) {
            state.key = key;
        },
        showif(state, sh) {
            state.showtable = sh;
        }
    }
});

// 创建 Vue 3 应用实例
const app = createApp(App);

// 使用路由
app.use(router);

// 使用 ElementPlus
app.use(ElementPlus);

// 使用 Vuex 存储
app.use(store);

// 设置全局属性
app.config.globalProperties.$message = ElMessage;
app.config.globalProperties.$cookie = Cookies;

// 设置 axios 全局配置
axios.defaults.emulateJSON = true;
app.config.globalProperties.$http = axios;

// 挂载应用
app.mount('#app');